From: Richard M. Stallman Date: Sat, 29 May 1993 18:14:34 +0000 (+0000) Subject: (c-up-conditional): Handle commented-out #-cmds properly. X-Git-Tag: archive/raspbian/1%29.2+1-2+rpi1^2~5^2~95804 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=1e2d7ccea08bd60e5e9ac8eb36d2c2fdc650a306;p=emacs.git (c-up-conditional): Handle commented-out #-cmds properly. --- diff --git a/lisp/progmodes/c-mode.el b/lisp/progmodes/c-mode.el index a9aab352c7b..ec4b2c646ab 100644 --- a/lisp/progmodes/c-mode.el +++ b/lisp/progmodes/c-mode.el @@ -1271,24 +1271,25 @@ When going forwards, `#elif' is ignored." ;; the regexp matcher. (funcall search-function "#[ \t]*\\(if\\|elif\\|endif\\)" - nil t) - (progn - (beginning-of-line) - (looking-at "^[ \t]*#[ \t]*\\(if\\|elif\\|endif\\)"))) - ;; Update depth according to what we found. + nil t)) (beginning-of-line) - (cond ((looking-at "[ \t]*#[ \t]*endif") - (setq depth (+ depth increment))) - ((looking-at "[ \t]*#[ \t]*elif") - (if (and forward (= depth 0)) - (setq found (point)))) - (t (setq depth (- depth increment)))) - ;; If this line exits a level of conditional, exit inner loop. - (if (< depth 0) - (setq found (point))) - ;; When searching forward, start from end of line - ;; so that we don't find the same line again. - (if forward (end-of-line)))) + ;; Now verify it is really a preproc line. + (if (looking-at "^[ \t]*#[ \t]*\\(if\\|elif\\|endif\\)") + (progn + ;; Update depth according to what we found. + (beginning-of-line) + (cond ((looking-at "[ \t]*#[ \t]*endif") + (setq depth (+ depth increment))) + ((looking-at "[ \t]*#[ \t]*elif") + (if (and forward (= depth 0)) + (setq found (point)))) + (t (setq depth (- depth increment)))) + ;; If this line exits a level of conditional, exit inner loop. + (if (< depth 0) + (setq found (point))) + ;; When searching forward, start from end of line + ;; so that we don't find the same line again. + (if forward (end-of-line)))))) (or found (error "No containing preprocessor conditional")) (goto-char (setq new found)))